package com.sandking.config;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.sql.DataSource;

import redis.clients.jedis.JedisPool;

/**
 * @UserName : SandKing
 * @DataTime : 2013年11月30日 下午5:09:04
 * @Description ：服务器配置
 */
public class SK_Config {
	/** 检查全部索引 */
	public static final int CHECK_ALL_INDEX = 1;
	/** 检查更新的索引 */
	public static final int CHECK_UPDATE_INDEX = 2;	
	/** 不检查索引 */
	public static final int NO_CHECK_INDEX = 3;			
	
	static DataSource logicDataSource;
	static DataSource designDataSource;
	static DataSource logDataSource;
	static DataSource configDataSource;
	static JedisPool jedisPoll;
	static ExecutorService inThreadPool = Executors.newCachedThreadPool();

	private SK_Config() {
	}

	public static void init(DataSource logicDataSource,
			DataSource designDataSource, DataSource logDataSource,
			DataSource configDataSource, JedisPool jedisPoll) {
		System.out.println(">>> SK_Config Init");
		SK_Config.logicDataSource = logicDataSource;
		SK_Config.designDataSource = designDataSource;
		SK_Config.logDataSource = logDataSource;
		SK_Config.configDataSource = configDataSource;
		SK_Config.jedisPoll = jedisPoll;
	}

	public static DataSource getLogicDataSource() {
		return logicDataSource;
	}

	public static DataSource getDesignDataSource() {
		return designDataSource;
	}

	public static DataSource getLogDataSource() {
		return logDataSource;
	}

	public static DataSource getConfigDataSource() {
		return configDataSource;
	}

	public static JedisPool getJedisPoll() {
		return jedisPoll;
	}

	public static ExecutorService getInThreadPool() {
		return inThreadPool;
	}

	public static Connection getConnection(DataSource dataSource) {
		try {
			return dataSource.getConnection();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
